package com.sl.ms.trade.controller;

import cn.hutool.core.bean.BeanUtil;
import com.sl.ms.trade.domain.request.NativePayDTO;
import com.sl.ms.trade.domain.response.NativePayResponseDTO;
import com.sl.ms.trade.entity.TradingEntity;
import com.sl.ms.trade.service.NativePayService;
import com.sl.ms.trade.service.NotifyService;
import com.sl.ms.trade.service.TradingService;
import com.sl.transport.common.exception.SLException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author wjh
 * @create 2023-09-22 15:39
 */
@Validated
@RestController
@Api(tags = "Native支付")
@RequestMapping("/native")
public class NativePayController {
    
    @Resource
    private NativePayService nativePayService;
    
    @Resource
    private NotifyService notifyService;

    /***
     * 扫码支付，收银员通过收银台或商户后台调用此接口，生成二维码后，展示给用户，由用户扫描二维码完成订单支付。
     *
     * @param nativePayDTO 扫码支付提交参数
     * @return 扫码支付响应数据，其中包含二维码路径
     */
    @PostMapping
    @ApiOperation(value = "统一收单线下交易", notes = "统一收单线下交易")
    @ApiImplicitParam(name = "nativePayDTO", value = "扫码支付提交参数", required = true)
    public NativePayResponseDTO createDownLineTrading(@RequestBody NativePayDTO nativePayDTO) {
        TradingEntity tradingEntity = BeanUtil.toBean(nativePayDTO, TradingEntity.class);
        TradingEntity downLineTrading = nativePayService.createDownLineTrading(tradingEntity);
        return BeanUtil.toBean(downLineTrading,NativePayResponseDTO.class);
    }

    
}
